From e580dcf18ddc6ce0aa1c503aff26043c5bc55ea1 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 6 Jun 2023 05:13:39 +0200 Subject: [PATCH] glx: Fake an X request to make GLX hack work Sometimes, GLX can decide to use the previous request serial when faking XErrors via __glXSendError() (look through the Mesa sources to enjoy). This can cause the error trap we just installed to not feel responsible for the error. And that makes GDK decide to immediately abort the application. That is not what we or GLX want. So we use a no-op X Request to bump the request number so that when GLX does its shenanigans, it uses a serial that our error trap will catch. Fixes a crash in mutter's CI which apparently manages to drive GLX without an X server. --- gdk/x11/gdkglcontext-glx.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gdk/x11/gdkglcontext-glx.c b/gdk/x11/gdkglcontext-glx.c index 4b0ff395be..283052244f 100644 --- a/gdk/x11/gdkglcontext-glx.c +++ b/gdk/x11/gdkglcontext-glx.c @@ -658,6 +658,13 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context, gdk_x11_display_error_trap_push (display); + /* Increase XNextRequest because GLX may fake errors with the last request + * and we want the error trap to catch them */ + XChangeWindowAttributes (GDK_DISPLAY_XDISPLAY (display), + GDK_X11_DISPLAY (display)->leader_window, + 0, + (XSetWindowAttributes[1]) { 0, }); + if (preferred_api == GDK_GL_API_GL) { api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy); -- 2.30.2